import createAxios from '/@/utils/axios-j'

export const url = '/admin/routine.Config/'

export const actionUrl = new Map([
    ['index', url + 'query'],
    ['add', url + 'add'],
    ['edit', url + 'upd'],
    ['del', url + 'del'],
    ['sendTestMail', url + 'sendTestMail'],
])

export function index() {
    return createAxios({
        url: actionUrl.get('index'),
        method: 'post',
        data: {},
    })
}

export function postData(action: string, data: anyObj) {
    return createAxios(
        {
            url: actionUrl.get(action),
            method: 'post',
            data: data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function del(obj: anyObj) {
    return createAxios(
        {
            url: actionUrl.get('del'),
            method: 'post',
            data: obj,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function postSendTestMail(data: anyObj, mail: string) {
    return createAxios(
        {
            url: actionUrl.get('sendTestMail'),
            method: 'POST',
            data: Object.assign({}, data, { testMail: mail }),
        },
        {
            showSuccessMessage: true,
        }
    )
}
